package cn.cs.controller;

import cn.cs.common.Dto;
import cn.cs.common.DtoUtil;
import cn.cs.service.AgentShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/agentShop")
public class AgentShopController {
    @Autowired
    private AgentShopService agentShopService;
    /****
     * 获取我的商铺信息
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/getMyShopInfo")
    @ResponseBody
    public Dto getMyShopInfo(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.getMyShopInfo(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }

    /****
     * 修改我的商铺信息
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/updateMyShop")
    @ResponseBody
    public Dto updateMyShop(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.updateMyShop(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }

    /****
     * 商铺首页信息
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/shopIndex")
    @ResponseBody
    public Dto shopIndex(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.shopIndex(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }

    /****
     * 商铺订单列表
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/shopOrderList")
    @ResponseBody
    public Dto shopOrderList(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.shopOrderList(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }

    /****
     * 确认发货
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/doSendPro")
    @ResponseBody
    public Dto doSendPro(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.doSendPro(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }


    /****
     * 资金管理首页
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/assetsManage")
    @ResponseBody
    public Dto assetsManage(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.assetsManage(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }
    /****
     * 营业额列表
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/assetsList")
    @ResponseBody
    public Dto assetsList(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.assetsList(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }


    /****
     * 申请结算
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/getSetMoney")
    @ResponseBody
    public Dto getSetMoney(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.getSetMoney(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }

    /****
     * 确定申请结算
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/doAppSet")
    @ResponseBody
    public Dto doAppSet(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=agentShopService.doAppSet(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("添加失败","002");
        }
        return dto;
    }

}
